package org.swift.mashup.engine.concurrency.memory;

import java.util.Collection;
import java.util.Collections;

import org.swift.commons.xml.XmlUtils;
import org.w3c.dom.Node;

public class ExceptionMemoryItem extends MemoryItem {

	private Exception exception;
	
	public ExceptionMemoryItem(int id, Exception item, MemoryType type) {
		super(id, type);
		this.exception = item;
	}

	@Override
	public Object getValue() {
		return exception;
	}

	@Override
	public Collection<Exception> toCollection() {
		return Collections.singletonList(this.exception);
	}

	@Override
	public Node toNode() {
		return XmlUtils.toNode("<exception>" + this.exception.getMessage() + "</exception>");
	}

	@Override
	public String toXML() {
		return "<exception>" + this.exception.getMessage() + "</exception>";
	}
	
	public String toString() {
		return this.exception.getMessage();
	}

}
